﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Web
{
    public partial class WebShop : System.Web.UI.Page
    {
        public string typename = "所有商品";
        public List<Model.tb_goods> list = new List<Model.tb_goods>();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                
                var test = Common.SqlExption.GetList<Model.tb_goods>().OrderBy(c => c.Hot).ThenBy(c => c.sellLevel).ToList();
                if (test.Count > 0)
                {
                    list = test;
                    if (Request.QueryString["Id"] != null)
                    {
                        int Id = 0;
                        if (int.TryParse(Request.QueryString["Id"], out Id))
                        {
                            list = list.Where(c => c.goods_type.Equals(Id)).ToList();
                            var tmodel = Common.SqlExption.GetList<Model.tb_goods_type>().FirstOrDefault(c => c.Id.Equals(Id));
                            if (tmodel!=null)
                            {
                                typename = tmodel.Name;
                            }
                        }
                    }
                }
            }
        }
    }
}